<!-- 封装获取文章列表下拉组件，便于复用 -->
<script setup>
  import { ref } from 'vue'
  import { artGetListService } from '@/api/artcile'

  // 接收父组件
  const prop = defineProps({
    cid: {
      type: [Number, String]
    }
  })
  // 发送给父组件
  const emit = defineEmits(['update:cid'])

  // 获取文章分类
  const dateList = ref([])
  const getList = async () => {
    const res = await artGetListService()
    dateList.value = res.data
    // console.log(dateList)
  }

  getList()
</script>

<template>
  <el-select :modelValue="cid" @update:modelValue="emit('update:cid', $event)">
    <el-option
      v-for="item in dateList"
      :key="item.id"
      :label="item.cate_name"
      :value="item.id"
    ></el-option>
  </el-select>
</template>
